package com.dex4d.ui.mine.activity;

import android.view.View;

import com.dex4d.R;
import com.dex4d.core.AppToolBarBaseActivity;
import com.dex4d.utils.LocaleUtil;
import com.dex4d.utils.SPUtil;
import com.dex4d.widgets.SimpleListItem;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by chengyuchun on 2018/11/2.
 */
public class SettingLanguageActivity extends AppToolBarBaseActivity {
    @BindView(R.id.sli_english)
    SimpleListItem sli_english;

    @BindView(R.id.sli_chinese)
    SimpleListItem sli_chinese;

    @Override
    protected void initToolbar() {
        showTitle(getString(R.string.language));
        showBackView();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_setting_language;
    }

    @Override
    protected void initVariables() {
        // 0 简体中文 1 繁体中文 2 English
       int currentLanguage = SPUtil.getInt("currentLanguage", -1);
       if(currentLanguage == 2) {
           sli_english.setArrowIcon(R.drawable.ic_selected);
           sli_english.setArrowDisplay(true);
           sli_chinese.setArrowDisplay(false);
       }else {
           sli_chinese.setArrowIcon(R.drawable.ic_selected);
           sli_chinese.setArrowDisplay(true);
           sli_english.setArrowDisplay(false);
       }
    }

    @OnClick({R.id.sli_english,R.id.sli_chinese})
    public void onViewClick(View view){
        switch (view.getId()){
            case R.id.sli_english:
                sli_english.setArrowDisplay(true);
                sli_chinese.setArrowDisplay(false);
                //SPUtil.putString(AppConstants.SP_CURRENCY_KEY,"usd");
                LocaleUtil.changeAppLanguage(this, 2);
                //openActivity(HomeActivity.class);
                break;
            case R.id.sli_chinese:
                sli_english.setArrowDisplay(false);
                sli_chinese.setArrowDisplay(true);
                LocaleUtil.changeAppLanguage(this, 0);
                //openActivity(HomeActivity.class);
                break;
        }
    }

    @Override
    protected void loadData() {

    }
}
